package com.chengwei.ch.busdemo.base;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;

@SuppressWarnings("ALL")
@SuppressLint("Registered")
public class BaseDialog extends Dialog {
    private BaseContract.DialogManager dialogManager;
    private Context context;

    public BaseDialog(Context context, BaseContract.DialogManager dialogManager, int themeResId) {
        super(context, themeResId);
        this.context = context;
        this.dialogManager = dialogManager;
    }

    /**
     * @param widthPercent 宽所占屏幕宽比
     * @param isOutCancel  点击对话框外是否可以关闭
     */
    void setWindowWidth(Float widthPercent, Boolean isOutCancel) {
        //getWindow().getAttributes().width = (int) (AppUtil.getScreenWidthHeight(context)[0] * widthPercent);
        setCancelable(true);
        setCanceledOnTouchOutside(isOutCancel);
    }

    void setHeighWidth(Float heightPercent) {
        //Log.d(AppConfig.TAG,"height:" + AppUtil.getScreenWidthHeight(context)[1] * heightPercent)
        // getWindow().getAttributes().height = (int) (AppUtil.getScreenWidthHeight(context)[1] * heightPercent);
    }

    @Override
    public void show() {
        super.show();
        dialogManager.onShow(this);
    }

    @Override
    public void dismiss() {
        super.dismiss();
        dialogManager.onDismiss(this);
    }


    interface OnConfirmListener {
        void onConfirmed();

        void onCanceled();
    }

    interface OnCloseListener {

    }

    interface OnCloseStrListener {
        void onClosed(String dataStr);
    }
}
